<template>
  <van-cell class="event-item"  
  :to="
  
  {
    name:'event',
    params:{
        eventId:event.id
    }
  }
  "
  
  >
    <template #right-icon>
<van-image 
width="100"
height="100"
position="left"
:src="`${url}`+event.logo"
@click="viewImage"
>
</van-image>

</template>
    <template #title>
     
     <span class="title van-multi-ellipsis--l2" >{{ event.name }}</span>
 </template>

 <template #label >
  <span>{{ event.users.name }}</span>-   
  <span>{{ dayjs().to(dayjs(event.createdAt)) }}[{{ event.count }}/{{ event.nums }}]</span><br>
  <van-tag type="success">{{ event.clubs.name }}</van-tag><br>
  <van-tag v-if="route.path!='/' &&  event.turnUser!='true'" type="danger">社团活动</van-tag>
         <van-tag v-if="route.path!='/' && event.turnUser=='true'" type="warning">全体活动</van-tag>
    </template>
  </van-cell>
</template>
 
<script>
import { ImagePreview } from 'vant';
import dayjs from "../../utils/day.js";
import { useRoute } from 'vue-router'
export default {
  props: {
    event: {
      type: Object,
      required: true
    }
  },
  mounted() {
    const route = useRoute();

if (route.path==='/') {

// 从 sessionStorage 中获取之前记录的滑块位置
const scrollY = sessionStorage.getItem('scrollY1');
// 如果存在记录，则滚动到该位置
if (scrollY) {
  window.scrollTo(0, parseInt(scrollY));
}
}else{

}
  },
  setup() {
    const url = import.meta.env.VITE_APP_URL + "/common/download?name=";
    const route = useRoute();
    return {
      url,
      dayjs,
      route
    };
  }
};
</script>
<style scoped> 
.event-item .title {
  font-size: 18px;
  color: #3a3a3a;
}
.event-item .van-cell__value {
  flex: unset;
  width: 232px;
  height: 146px;
  padding-left: 25px;
}
.event-item .right-cover {
  width: 132px;
  height: 146px;
}

.event-item .label-info-wrap span {
  font-size: 14px;
  color: #b4b4b4;
  margin-right: 25px;
}
.event-item .cover-wrap {
  display: flex;
}
.event-item .cover-wrap .cover-item {
  /* 平分宽度 */
  flex: 1;
  padding-right: 4px;
}
.event-item .van-cell__value {
  width: 200px;
}

.event-item .label-info-wrap span {
  font-size: 14px;
  color: #b4b4b4;
  margin-right: 25px;
  word-break: break-all;
}

</style>
